package main

import "fmt"

type Books struct {
	title   string
	author  string
	subject string
	book_id int
}

func main() {
	var Book1 Books /* 声明 Book1 为 Books 类型 */
	var Book2 Books /* 声明 Book2 为 Books 类型 */

	/* book 1 描述 */
	Book1.title = "Go 语言"
	Book1.author = "www.runoob.com"
	Book1.subject = "Go 语言教程"
	Book1.book_id = 6495407

	/* book 2 描述 */
	Book2.title = "Python 教程"
	Book2.author = "www.runoob.com"
	Book2.subject = "Python 语言教程"
	Book2.book_id = 6495700

	//因为这个方法接收的是指针，所以要传指针
	printBook(&Book1)

	/* 打印 Book2 信息 */
	showBook(Book2)

	fmt.Println(Book1.title)
	fmt.Println(Book2.title)
}

//接收的是结构体的指针 看到*Books ，要明白它是一个数据类型。即Books这个结构体的指针
func printBook(book *Books) {
	fmt.Printf("Book title : %s\n", book.title)
	book.title = "haha" //会改变原来的数据
}

//接收的是结构体
func showBook(book Books) {
	fmt.Printf("Book title : %s\n", book.title)
	book.title = "new" //不会改变原来的数据
}
